<template>
  <div class="order-right">
    <!-- 订单内容 -->
    <div class="order-content">
      <!-- 标题部分 -->
      <div class="title">
        <h3>我的订单</h3>
      </div>
      <!-- 表头部分 -->
      <div class="chosetype">
        <table>
          <thead>
          <tr>
            <th width="29%">商品</th>
            <th width="31%">订单详情</th>
            <th width="13%">收货人</th>
            <th>金额</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
          </thead>
        </table>
      </div>
      <!-- 订单部分 -->
      <div class="orders">
        <!-- 几个订单？循环遍历订单列表数据（Records->List） -->
        <table class="order-item" v-for="(order, index) in list" v-bind:key="order.id">
          <thead>
          <tr>
            <th colspan="5">
              <span class="ordertitle">
                <span>订单时间：{{ order.createTime }}&nbsp;</span>
                <span>订单编号：{{ order.outTradeNo }}&nbsp;</span>
                <span class="pull-right delete">
                  <!-- 删除功能（这货没提供，不然根据order.id删除订单） -->
                  <img src="../images/delete.png" alt="" title="">
                </span>
              </span>
            </th>
          </tr>
          </thead>
          <tbody>
          <!-- 每个订单中几个商品？订单展示购买商品的地方 -->
          <tr v-for="(cart, index) in order.orderDetailList" v-bind:key="index">
            <td width="60%">
              <div class="typographic">
                <img v-bind:src="cart.imgUrl" alt="" title="" style="width: 82px; height: 82px;">
                <a href="#" class="block-text">{{ cart.skuName }}</a>
                <span>x{{ cart.skuNum }}</span>
                <a href="#" class="service">售后申请</a>
              </div>
            </td>
            <td rowspan="2" width="8%" class="center">{{ order.consignee }}</td>
            <td rowspan="2" width="13%" class="center">
              <ul class="unstyled">
                <li>总金额¥{{ order.totalAmount }}.00</li>
                <li>在线支付</li>
              </ul>
            </td>
            <td rowspan="2" width="8%" class="center">
              <a href="#" class="btn">{{ order.orderStatusName }}</a>
            </td>
            <td rowspan="2" width="13%" class="center">
              <ul class="unstyled">
                <li>
                  <a href="#" target="_blank">评价</a>&nbsp;|
                  <a href="#" target="_blank">晒单</a>
                </li>
              </ul>
            </td>
          </tr>
          </tbody>
        </table>

        <!-- 订单部分：静态资源 -->
        <table class="order-item">
          <thead>
          <tr>
            <th colspan="5">
              <span class="ordertitle">
                <span>2000-00-00 00:00 订单编号：ABCDEFG0000000000000000</span>
                <span class="pull-right delete">
                  <img src="../images/delete.png" alt="">
                </span>
              </span>
            </th>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td width="60%">
              <div class="typographic">
                <img src="../images/goods.png" alt="">
                <a href="#" class="block-text">静态 正品玛姬儿压缩面膜无纺布纸膜100粒 送泡瓶面膜刷喷瓶 新款</a>
                <span>x10</span>
                <a href="#" class="service">售后申请</a>
              </div>
            </td>
            <td rowspan="2" width="8%" class="center">小丽</td>
            <td rowspan="2" width="13%" class="center">
              <ul class="unstyled">
                <li>总金额¥138.00</li>
                <li>在线支付</li>
              </ul>
            </td>
            <td rowspan="2" width="8%" class="center">
              <a href="#" class="btn">已完成 </a>
            </td>
            <td rowspan="2" width="13%" class="center">
              <ul class="unstyled">
                <li>
                  <a href="javascript:void(0);" target="_blank">评价|晒单</a>
                </li>
              </ul>
            </td>
          </tr>
          <tr>
            <td width="50%">
              <div class="typographic">
                <img src="../images/goods.png" alt="">
                <a href="#" class="block-text">静态 正品玛姬儿压缩面膜无纺布纸膜100粒 送泡瓶面膜刷喷瓶 新款</a>
                <span>x20</span>
                <a href="#" class="service">售后申请</a>
              </div>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
      <!-- 分页器部分 -->
      <div class="choose-order">
        <el-pagination
            v-on:size-change="handleSizeChange"
            v-on:current-change="handleCurrentChange"
            v-bind:current-page.sync="searchParams.pageNo"
            v-bind:page-size="searchParams.pageSize"
            v-bind:page-sizes="[5, 10, 20, 50]"
            v-bind:total="total"
            layout="total, prev, pager, next, sizes"
            background>
        </el-pagination>
      </div>
    </div>

    <!--猜你喜欢-->
    <div class="like">
      <h4 class="kt">猜你喜欢</h4>
      <ul class="like-list">
        <li class="likeItem">
          <div class="p-img">
            <img src="../images/itemlike01.png" alt=""/>
          </div>
          <div class="attr">
            <em>DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本</em>
          </div>
          <div class="price">
            <em>¥</em>
            <i>3699.00</i>
          </div>
          <div class="commit">已有6人评价
          </div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="../images/itemlike02.png" alt=""/>
          </div>
          <div class="attr">
            Apple苹果iPhone 6s/6s Plus 16G 64G 128G
          </div>
          <div class="price">
            <em>¥</em>
            <i>4388.00</i>
          </div>
          <div class="commit">已有700人评价
          </div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="../images/itemlike03.png" alt=""/>
          </div>
          <div class="attr">DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本
          </div>
          <div class="price">
            <em>¥</em>
            <i>4088.00</i>
          </div>
          <div class="commit">已有700人评价
          </div>
        </li>
        <li class="likeItem">
          <div class="p-img">
            <img src="../images/itemlike04.png" alt=""/>
          </div>
          <div class="attr">DELL戴尔Ins 15MR-7528SS 15英寸 银色 笔记本
          </div>
          <div class="price">
            <em>¥</em>
            <i>4088.00</i>
          </div>
          <div class="commit">已有700人评价
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import {mapState} from "vuex";

export default {
  name: 'MyOrderView',
  data() {
    return {
      page: 1,
      limit: 4,
      searchParams: {
        // 本地商品分页搜索条件
        pageNo: 1,
        pageSize: 5
      },
    }
  },
  computed: {
    ...mapState({
      list: state => {
        return state.center.list;
      },
      total: state => {
        return state.center.total;
      }
    }),
  },
  methods: {
    initialData() {
      const { page, limit } = this;
      this.$store.dispatch("reqMyOrderList", {page, limit});
    },
    handleSizeChange(val) {
      this.searchParams.pageSize = val;
      this.initialData();
    },
    handleCurrentChange(val) {
      this.searchParams.pageNo = val;
      this.initialData();
    }
  },
  mounted() {
    this.initialData();
  }
}
</script>

<style lang="less" scoped>

</style>
